import glumpy
import cv2
from gl_shapes import *

fig  = glumpy.figure(size=(500,500))
img_arr = cv2.imread('data/obama_peace_sign.jpg')
img_arr = cv2.cvtColor(img_arr, cv2.COLOR_RGB2BGR)
image = glumpy.image.Image(img_arr)
image_two = glumpy.image.Image(img_arr)

dimensions = img_arr.shape

height = dimensions[0]
width = dimensions[1]
depth = dimensions[2]

my_pixel = img_arr[height/2,width/2]

print my_pixel

my_pixel = my_pixel/255.

print my_pixel
smooth()

def on_draw( ):
	fig.clear(0,0,0,0)

	# now that we have everything set up we probably want to render the image onto the 'canvas'

	# image.draw( x=fig.x, y=fig.y, z=0, width=image.width, height=image.height)
	
	# but what if we want to center the image in the window

	image.draw( x=0,y=0, z=0, width=image.width, height=image.height )
	# image_two.draw( x=0.0, y=10.0, z=0, width=image.width/4, height=image.height/4 )

	# what if we want to draw some shapes with the image?
	# no problem, but we need to import the gl_shapes library first!
	# and then draw some shapes below

	rectangle((280,350,0.0), 100, 100, 45.0, color=(my_pixel[0],my_pixel[1],my_pixel[2],.5))


fig.window.push_handlers(on_draw)
fig.window.set_title("my image viewer") # also, we can name the window if we like!
fig.show()